<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    function Cat(name,color) {
            this.name = name,
            this.color = color
        } 
        Cat.prototype.species = "猫猫";
        Cat.prototype.call = function(){
                console.log("猫猫",this.species);
            };
        Cat.prototype.skill = function(){
                console.log("捉老鼠");
            };
        Cat.prototype.say = function(){
                console.log(this.color,this.name);
            };
     

     console.dir(Array);
     var arr = new Array(1,2,3,4,5);
     console.log(arr);

    //  给构造函数Array拓展 方法(动态方法  => 给数组(实例化对象)使用)
        Array.prototype.myKeys = function * () {      // this ->  调用此方法的实例化对象  谁调用就指向谁
            console.log("这是我创建的属性");
            for(var i = 0; i< this.length; i++) {   // this指向调用此方法的实例化对象 arr
                yield this[i];
            }
        }
        var obj = arr.myKeys();       // this -> arr
        console.log(obj);

        for(val of obj) {
            console.log(val);
        } 
</script>
</html>